<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册 - 云文档平台</title>
    <link rel="stylesheet" href="static/css/bootstrap.min.css">
    <link rel="stylesheet" href="static/css/auth.css">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        if(!window.jQuery) {
            document.write('<script src="static/js/jquery-3.6.0.min.js"><\/script>');
        }
    </script>
</head>
<body>
<div class="auth-container">
    <div class="card">
        <div class="card-header">
            <h4>用户注册</h4>
        </div>
        <div class="card-body">
            <form id="registerForm">

                <div class="form-group">
                    <label for="regUsername">用户名</label>
                    <input type="text" class="form-control" id="regUsername"
                           placeholder="4-20位字母、数字或中文" required>
                    <small class="form-text text-muted" id="usernameTip"></small>
                </div>

                <div class="form-group">
                    <label for="regPassword">密码</label>
                    <input type="password" class="form-control" id="regPassword"
                           placeholder="8-20位，包含大小写字母和数字" required>
                    <small class="form-text text-muted">必须包含大小写字母、数字和特殊符号</small>
                </div>

                <div class="form-group">
                    <label for="regEmail">邮箱</label>
                    <div class="input-group">
                        <input type="email" class="form-control" id="regEmail"
                               placeholder="请输入有效邮箱" required>
                        <div class="input-group-append">
                            <button class="btn btn-outline-secondary" type="button"
                                    id="sendCodeBtn" onclick="sendEmailCode()">
                                发送验证码
                            </button>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <label for="emailCode">邮箱验证码</label>
                    <input type="text" class="form-control" id="emailCode"
                           placeholder="请输入6位验证码" required>
                </div>

<!--                <div class="form-group captcha-group">-->
<!--                    <label for="regCaptcha">图形验证码</label>-->
<!--                    <div class="input-group">-->
<!--                        <input type="text" class="form-control" id="regCaptcha"-->
<!--                               placeholder="请输入验证码" required>-->
<!--                        <div class="input-group-append">-->
<!--                            <img id="regCaptchaImg" src="" alt="验证码"-->
<!--                                 onclick="refreshRegCaptcha()">-->
<!--                            <input type="hidden" id="regCaptchaToken">-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->

                <button type="submit" class="btn btn-primary btn-block">注册</button>
            </form>
            <div class="auth-links">
                已有账号？<a href="/Cloud/login.html">立即登录</a>
            </div>
        </div>
    </div>
</div>

<script src="static/js/auth.js"></script>
<script>
    $(document).ready(function() {
        refreshRegCaptcha();
        $("#regUsername").on("input", function() {
            checkUsernameAvailable($(this).val());
        });
        $("#registerForm").submit(function(e) {
            e.preventDefault();
            register();
        });
    });

    function refreshRegCaptcha() {
        $.get("/Cloud/captcha", function(res) {
            $("#regCaptchaImg").attr("src", res.image);
            $("#regCaptchaToken").val(res.token);
        });
    }
</script>
</body>
</html>